package com.swlz.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.swlz.Const;
import com.swlz.R;
import com.swlz.service.UserService;
import com.swlz.service.impl.UserServiceImpl;
import com.swlz.vo.LoginUser;

/**
 * <pre>
 * - 登录
 * ClassName : com.swlz.servlet.LoginServlet
 * Author : swlz
 * E-Mail : 2233875735@qq.com
 * Date : 2020-8-14 15:05:18
 * Version : 1.0
 * Copyright 2020 swlz.top Inc. All rights reserved. 
 * Warning: this content is only for internal circulation of the company. It is forbidden to divulge it or use it for other commercial purposes
 * </pre>
 *
 */
@WebServlet("/login.let")
public class LoginServlet extends HttpServletSupport {
	
	private UserService service = new UserServiceImpl();

	public R<?> execute(HttpServletRequest request,HttpSession session)throws Exception{
		Const.codeVerify(session, request.getParameter("code"));
		LoginUser user = service.login(request.getParameter("userName"), request.getParameter("userPwd"));
		session.setAttribute(Const.LOGIN_USER_SESSION_NAME, user);
//		return "/aa/bb";//请求转发
//		return "forward:/aa/bb.jsp";//请求转发
//		return "redirect:/aa/bb.jsp";//响应重定向
		return R.ok(user);
	}
}
